|
|
| GmPrintUtils (const GmLogCategory &logger, GmLogLevel level=GM_EXT_INFO, int opt=GM_PRINT_DEFAULT) |
| | Constructor receiving the logger and level used to print data, along with print options.
|
| |
|
void | setOption (GmPrintUtilsFlags opt, bool mode) |
| | Enable or desable a printing option.
|
| |
|
void | setOptions (int options) |
| | Sets all printing options.
|
| |
| void | setFirstGhostIndex (int index) |
| | Informs the printer about the border between normal and ghost nodes.
|
| |
| GmValueAccessor * | valueAccessorForStringColumn (QString title, const QStringList &data, int width) |
| | Returns an accessor suitable for printing a string column with printValueTable()
|
| |
| void | printValueTable (const QList< GmValueAccessor * > &dataList, QString title="", const QList< int > &columnWidths=QList< int >(), const GmPCR *pcr=NULL) |
| | Prints a table of values where each accessor is a table column, using the object configured logger and options.
|
| |
| void | printCellTable (const GmCellMesh *mesh, const QList< GmCellAccessor * > &dataList, QString title="", const QList< int > &columnWidths=QList< int >(), int ip=-1) |
| | Prints a table of values where each cell accessor is a table column, using the object configured logger and options.
|
| |
| void | printGaussTable (const GmElementMesh *mesh, const QList< GmGaussAccessor * > &dataList, QString title="", const QList< int > &columnWidths=QList< int >()) |
| | Prints a table of values where each Gauss accessor is a table column, using the object configured logger and options.
|
| |
| template<class A > |
| void | addDataColumnSizes (const QList< A * > &dataList, const QList< int > &colWidths, QList< int > &sizes) |
| | Discovers the size of each data column, taking into account the accessor metadata, user defined column widths and object options, and adds them to the size list.
|
| |
| template<class A > |
| int | printColumnHeaders (QString title, const QStringList &extraCols, const QList< A * > &dataList, const QList< int > &colWidths) |
| | Prints a set of column headers.
|
| |
|
template<class A > |
| void | buildReverseConstMaps (const QList< A * > &dataList, QList< QMap< double, QString > > &revConstMapList) |
| | Aux function to build the reverse const maps used when print options include GM_PRINT_CONSTMAP.
|
| |
|
| static bool | parseValueIds (lua_State *L, int index, QString fname, QStringList &valueList, QList< Unit > &unitList) |
| | Auxiliary function used to parse a table parameter describing values to be printed or saved.
|
| |
|
static QList< int > | parseColumnWidths (lua_State *L, int index, QString fname, int ncol) |
| | Auxiliary function used to parse column sizes.
|
| |
| static void | parsePrintOptions (lua_State *L, int index, QString fname, int &options, int *state) |
| | Auxiliary function used to parse print options given in a Lua table. Common code used by print process functions to parse print option tables.
|
| |
|
static QString | leftStr (QString str, int width, bool clip=false) |
| | Returns the given string left aligned into a space of width characters.
|
| |
|
static QString | centerStr (QString str, int width, bool clip=false) |
| | Returns the given string centered into a space of width characters.
|
| |
|
static QString | rightStr (QString str, int width, bool clip=false) |
| | Returns the given string right aligned into a space of width characters.
|
| |
|
static QString | quoteStr (QString str, QString separator=",") |
| | Returns the given string quoted for CSV saving.
|
| |
| static void | progressBar (int i, int size, int &mark, const GmLogCategory &logger, int freq=10) |
| | Auxiliary function used to display a progress status of a countable/iterative process.
|
| |
|
|
template<class A > |
| GMC_API_EXPORT void | addDataColumnSizes (const QList< A * > &dataList, const QList< int > &colWidths, QList< int > &sizes) |
| |
|
template<class A > |
| GMC_API_EXPORT int | printColumnHeaders (QString title, const QStringList &extraCols, const QList< A * > &dataList, const QList< int > &colWidths) |
| |
|
template<class A > |
| GMC_API_EXPORT void | buildReverseConstMaps (const QList< A * > &dataList, QList< QMap< double, QString > > &revConstMapList) |
| |
|
QString | center (QString val, int size) |
| | Given a string, returns a new string with the given size, where val is centered on the available space. If the size of val is greater than size, returns val, clipped to size if options includes GM_PRINT_CLIP_TITLES.
|
| |
Groups utilitary routines for pretty printing data.
| void GmPrintUtils::parsePrintOptions |
( |
lua_State * | L, |
|
|
int | index, |
|
|
QString | fname, |
|
|
int & | options, |
|
|
int * | state ) |
|
static |
Auxiliary function used to parse print options given in a Lua table. Common code used by print process functions to parse print option tables.
The following fields are parsed from the Lua table. Each one (except for the state field) corresponds to a flag in GmPrintUtilsFlags (but not all flags are parsed in this function since some of them represent the presence or not of a column and are not given by the option table).
Each table option is a boolean flag or numeric value associated to a table field. When an option is not present in the table its default value will be used. Available options are: 'state' – The state number used to find values when the attribute/ state var has an associated history. Default = 0 (present state) If the state is invalid for an accessor, the default will be used for it. 'units' – Should we print units in column title? Default = true 'unit_line' – Should we print units in the header in a separate line? Default = false 'eval_functions' – Should we evaluate functions or do we print its name? Default = false 'def_nil' – Should we print default values as 'nil'? Default = false 'const_map' – Should we try to translate values back to strings when a scalar data column has an associated const map? Default = false 'line_numbers' – Should we print line numbers on the left margin? Default = true 'active_only' – Should we print only active cells? Default = true 'node_geometry' – Should we print common geometry nodes? Default = true 'node_ghost' – Should we print ghost nodes (if they exist)? Default = true 'mark_ghost' – Should we add a '|' between geometry and ghost node numbers? Default = false 'clip_title' – Should we clip column titles when the user gave us a width and the title is bigger than that? Default = true 'header_title' – Should we print a title in the header, for the entire table? Default = false 'trailler' – Should we add a closing trailer line to the table? Default = false 'int_order' – Should we order the rows in the table according to the internal id (instead of the model id)? Default = false
If the supplied table index is not a table, this function will generate an error by calling luaL_error().
- Parameters
-
| L | The current Lua state |
| index | The position on the Lua stack where the options table can be found |
| fname | The called process function name, used for error messages. |
| options | Integer filled with the bitwise or of the selected flags. |
| state | Returns the desired state number. |
Auxiliary function used to parse a table parameter describing values to be printed or saved.
The parameter containing the values description should be in the Lua stack in the index position. It should be a string with the name of the value to be printed/exported or a list with the names of values. Can be nil.
Optionally, value names can have a suffix surrounded by () with the desired unit (ex: T(K) would ask for a temperature value named T and with values converted, if needed, to Kelvin).
If the parameter at index is nil or missing, the function returns false. On errors, the function does not return, throwing a message using lua_error()
- Parameters
-
| L | The Lua state |
| index | Position in the stack with the value list description |
| valueList | List filled with value names (stripped from unit definitions) |
| unitList | List with size equal to valueList with defined units or Unit() |
| fname | The name of the called function, used on error messages |
Returns an accessor suitable for printing a string column with printValueTable()
Receives as parameters the column title, the string list with the column values and the desired column width.
IMPORTANT: The accessor returned by this function should be used ONLY as a parameter to printValueTable(). PLEASE, do not use it in any other way. REALLY!
Please remember to deallocate the accessor after its use.